package cn.agiledata.bank.common.service.email;

import java.util.Date;
import java.util.Map;

import cn.agiledata.bank.common.service.NotifyMail;
import cn.agiledata.bank.common.util.Constant;
import cn.agiledata.bank.common.util.DateUtil;
import cn.agiledata.bank.common.util.WeatherUtil;
import cn.agiledata.bank.hibernateBean.ScoresHis;
import cn.agiledata.bank.hibernateBean.SubAccount;
import cn.agiledata.bank.hibernateBean.Transaction;

public class ControversialResult extends NotifyMail{
	  private SubAccount email;
	    private String warn;
	    private String type;
	    private String mobilemessage="欢迎使用支付系统";
	    
	    public String getMobilemessage() {
			return mobilemessage;
		}

		public void setMobilemessage(String mobilemessage) {
			this.mobilemessage = mobilemessage;
		}

		public String getType() {
			return type;
		}

		public void setType(String type) {
			this.type = type;
		}
		public SubAccount getEmail() {
			return email;
		}

		public void setEmail(SubAccount email) {
			this.email = email;
		}

		public String getWarn() {
			return warn;
		}

		public void setWarn(String warn) {
			this.warn = warn;
		}

		protected SubAccount setMailContext(Map vnvMap, Transaction tran, ScoresHis score) {
			// TODO Auto-generated method stub
		//	vnvMap.put("transid", tran.getTransId());
			String now = DateUtil.date2String(new Date());
			vnvMap.put("tranTime", now);
			vnvMap.put("tranId", tran.getTransId());
			vnvMap.put("type", getType());
			vnvMap.put("amount", Math.abs(tran.getAmount().doubleValue())+"");
			vnvMap.put("mobilemessage", getMobilemessage());
			String creditName = WeatherUtil.getNameOrEmailOrMobileByAccount(tran.getCredit().getAccount());
			String debitName = WeatherUtil.getNameOrEmailOrMobileByAccount(tran.getDebit().getAccount());
			if(tran.getCredit().getId().longValue()==getEmail().getId().longValue()){
				
				//vnvMap.put("tranTime", now);
				vnvMap.put("other",debitName );
				vnvMap.put("fee", Math.abs(tran.getCreditFee().doubleValue())+"");
				//
				if (tran.getTransStatus().equals(Constant.TRANS_STATUS_REFUNDSUCC)){
				vnvMap.put("trueamount", Math.abs(tran.getAmount().doubleValue())+"");}else{
					double trueamount = tran.getAmount().doubleValue()-tran.getDebitFee().doubleValue();
					vnvMap.put("trueamount", trueamount+"");
				}
				vnvMap.put("name", creditName);
			}else{
				
				vnvMap.put("other", creditName);
				vnvMap.put("fee", Math.abs(tran.getDebitFee().doubleValue())+"");
				//double trueamount = tran.getAmount().doubleValue()+tran.getDebitFee().doubleValue();
				if (tran.getTransStatus().equals(Constant.TRANS_STATUS_REFUNDSUCC)){
					vnvMap.put("trueamount", Math.abs(tran.getAmount().doubleValue())+"");}else{
						double trueamount = tran.getAmount().doubleValue()+tran.getDebitFee().doubleValue();
						vnvMap.put("trueamount", trueamount+"");
					}
				
				vnvMap.put("name", debitName);
			}
			
			vnvMap.put("titlemessage", getWarn());
			vnvMap.put("warn","欢迎使用支付系统");
//			
			
			return getEmail();
		}

	}
